package com.bianguo.android.pigeondemo.model;

import com.bianguo.android.pigeondemo.retrofit.BaseSubscriber;
import com.bianguo.android.pigeondemo.retrofit.ComposeTransform;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2018/6/4.
 */

public class BaseModel {

    protected ModelFactory mModelFactory;

    public BaseModel() {
        mModelFactory = ModelFactory.getInstance();
    }

    public <T> Disposable doSubscribe(Observable<T> observable, Consumer<T> consumer, Consumer<? super Throwable> onError) {
        return observable.compose(new ComposeTransform<T>())
                .subscribe(consumer, onError);
    }

    public <T> void doSubscribe(Observable<T> observable, BaseSubscriber<T> subscriber) {
        observable.compose(new ComposeTransform<T>())
                .subscribe(subscriber);
    }
}
